package nuaa.service;

import nuaa.domain.OrdinaryUser;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 收藏的事务层处理类
 */
public class CollectionService {

    /*获取groupService*/
    private GroupService groupService=new GroupService();

    public CollectionService() throws IOException {
    }

    /**
     * 根据collectionId从数据库中删除收藏对象
     * @param collectionId
     */
    public void deleteCollection(Integer collectionId, HttpServletRequest request) throws IOException {
        //1.通过session获取当前用户的Id
        OrdinaryUser user = (OrdinaryUser) request.getSession().getAttribute("user");
        Integer userId = user.getUserId();
        System.out.println("userId="+userId);
        //2.调用UserAndCollectionService方法删除数据表中记录
        UserAndCollectionService userAndCollectionService = new UserAndCollectionService();
        userAndCollectionService.delete(userId,collectionId);
    }

    /**
     * 提交收藏
     */
    public void addCollection(Integer groupId){
        //1.获取group对应的destinations

        //2.destinations和time放到collection数据表中

        //3.collectionId和userId一起放入userandcollection表中
    }
}
